#include <functional>
#include <vector>
#include <queue>
#include <iostream>
using namespace std;
class Solution {
public:
    int findKthLargest(vector<int>& nums, int k) {
	    std::priority_queue<int,vector<int>,greater<int>> que;
	    for(auto p = nums.begin();p != nums.end();++p){
		    if(que.size() < k){
			 que.push(*p);  
		    }
		    else {
		    	if(*p > que.top())
			{
				que.pop();
				que.push(*p);
			}
		    }
	    }
	    return que.top();
    }
};

int main()
{
	vector<int> a = {3,2,3,1,2,4,5,5,6};
	Solution s;
	cout<<s.findKthLargest(a, 4);
}
